using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using RAIN.Core;
using RAIN.Action;
using RAIN.Motion;
using RAIN.Representation;

[RAINAction("MoveInArea")]
public class ChooseMoveAreaWaypoint : RAINAction
{
	private GameObject _avoidTarget;
	private MoveLookTarget _nextMovePoint;
	private Vector3 moveTarget;
	public Expression moveTargetName;

	//private static int _wpCurrent = -1;

    public ChooseMoveAreaWaypoint()
    {
        ActionName = "ChooseMoveAreaWaypoint";

    }

	public override void Start(RAIN.Core.AI ai)
	{
		_nextMovePoint = new MoveLookTarget()
		{
			VectorTarget = ai.Body.GetComponent<EnemyMoveScript2>().getMoveTarget()
		};
		ai.Motor.moveTarget = _nextMovePoint;
		base.Start(ai);
	}
	
	public override ActionResult Execute(RAIN.Core.AI ai)
	{
		/*We will move to the target assigned above with ai.Motor.moveTarget
          as long as we are not already there. 
          This will exit when we are at the target location.
          If this script is allowed to continue running a new target location
          will be assigned in the Start method above. */
		if (!ai.Motor.Move()) {
			return ActionResult.RUNNING;
		}
		
		return ActionResult.NONE;
	}
	
	public override void Stop(RAIN.Core.AI ai)
	{
		base.Stop(ai);
	} 
}